// get Language
function getlan() {
	$
			.ajax({
				type : "get",
				url : "/main/infoMap",
				data : "",
				success : function(data) {
					var obj = JSON.parse(data)
					var list = obj.lan_list;
					var key = obj.country_id;
					var content = "";
					if (list.length > 0) {
						for (var i = 0; i < list.length; i++) {
							var country = list[i];
							var cls = (country.country_id == key ? "country_list_span_on"
									: "country_list_span");
							content += "<span id='span_" + country.country_id
									+ "' class='" + cls
									+ "' onclick=refreshLan('"
									+ country.country_id + "')>"
									+ country.country_code + "</span>";
							if (i < list.length - 1) {
								content += "|";
							}
						}
					}
					$("#country_list").html(content);
				}
			});

}

function refreshLan(id) {
	document.cookie = "country_id" + "=" + id + ";"
	document.getElementById("a_reload").click();
	// location.href="www.baidu.com";
	// $("#form2").submit();
	// $("#a_login").click();
	// location.href=window.location.href;

}
// 渲染数据
function transData() {
	var transList = $(".info_transe");
	$.each(transList, function(i) {// 循环得到不同的id的值
		var idValue = $(".info_transe").eq(i).attr("id");
		if (idValue != '') {
			getCountry(idValue);
		}
	});
}

// get country
function getCountry(key) {
	if (key != "") {
		$.ajax({
			type : "post",
			url : "/main/detail/" + key,
			data : "",
			success : function(data) {
				$("#" + key).text(data);
			}
		});

	}

}

function logout() {
	location.href = "/login";
}

function getCookie(name) {
	var strcookie = document.cookie;// 获取cookie字符串
	var arrcookie = strcookie.split("; ");// 分割
	// 遍历匹配
	for (var i = 0; i < arrcookie.length; i++) {
		var arr = arrcookie[i].split("=");
		if (arr[0] == name) {
			return arr[1];
		}
	}
	return "";
}